<?php

/***

LZRoster: A roster for World of Warcraft.
Copyright (C) 2007  Emmanuel Cron

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

***/

require_once dirname(__FILE__)."/Localization.class.php";
require_once dirname(__FILE__)."/Tooltip.class.php";

class SubscriptionDisplayer
{	
	static private $instance;
	
	private $localization;
	private $tooltip;
	
	private function __construct()
	{
		$this->localization = Localization::GetInstance();
		$this->tooltip = Tooltip::GetInstance();
	}
	
	static function GetInstance()
	{
		if ( empty(self::$instance) )
		{
			self::$instance = new SubscriptionDisplayer();
		}
		
		return self::$instance;
	}
	
	function Name($subscription)
	{
		$string = null;
		
		$string .= $subscription->GetName();
		$string .= " ";
		$string .= "(";
		$string .= $subscription->GetNickname();
		$string .= ")";
		
		return $string;
	}
	
	function Nickname($subscription)
	{
		$string = null;
		
		$string .= $subscription->GetNickname();
		
		return $string;
	}
	
	function DetailObjectsUpdated($subscription)
	{
		$string = null;
		
		$string .= "(";
		$string .= $subscription->GetNbItemsUpdated();
		$string .= " ";
		$string .= $this->localization->Get('items');
		$string .= ", ";
		$string .= $subscription->GetNbSpellsUpdated();
		$string .= " ";
		$string .= $this->localization->Get('spells');
		$string .= " &amp; ";
		$string .= $subscription->GetNbReagentsUpdated();
		$string .= " ";
		$string .= $this->localization->Get('reagents');
		$string .= ")";
		
		return $string;
	}
	
	function TotalObjectsUpdated($subscription)
	{
		$string = null;
		
		$string .= $subscription->GetNbItemsUpdated()+$subscription->GetNbSpellsUpdated()+$subscription->GetNbReagentsUpdated();
		
		return $string;
	}
	
	function __ChangePassword($subscription)
	{
		$string = null;
		
		$string .= "<form action='admin.php' method='post'>";
		$string .= "<div>";
		$string .= $this->localization->Get('new password');
		$string .= "<input type='password' name='new_pass' style='vertical-align: middle; width: 75px;' />";
		$string .= " ";
		$string .= "<input type='submit' name='a_chg_pwd' value='".$this->localization->Get('change')."' style='vertical-align: middle; width: auto;'";
		$string .= "onclick=\"return confirm('".$this->tooltip->Flatten( $this->localization->Get('do you really want to change the password for this account?') )."');\" ";
		$string .= "/>";
		$string .= "<input type='hidden' name='name' value='".$subscription->GetName()."' />";
		$string .= "</div>";
		$string .= "</form>";
		
		return $string;
	}
	
	function __ChangeNickname($subscription)
	{
		$string = null;
		
		$string .= "<form action='admin.php' method='post'>";
		$string .= "<div>";
		$string .= $this->localization->Get('new nickname');
		$string .= "<input type='text' name='new_nickname' style='vertical-align: middle; width: 75px;' value='".$subscription->GetNickname()."' />";
		$string .= " ";
		$string .= "<input type='submit' name='a_chg_nickname' value='".$this->localization->Get('change')."' style='vertical-align: middle; width: auto;' ";
		$string .= "onclick=\"return confirm('".$this->tooltip->Flatten( $this->localization->Get('do you really want to change the nickname for this account?') )."');\" ";
		$string .= "/>";
		$string .= "<input type='hidden' name='name' value='".$subscription->GetName()."' />";
		$string .= "</div>";
		$string .= "</form>";
		
		return $string;
	}
	
	function __Delete($subscription)
	{
		$string = null;
		
		$string .= "<form action='admin.php' method='post'>";
		$string .= "<div>";
		$string .= "<input type='submit' name='a_del' value='".$this->localization->Get('delete')."' style='vertical-align: middle; width: auto;'";
		$string .= "onclick=\"return confirm('".$this->tooltip->Flatten( $this->localization->Get('do you really want to delete this acocunt from the roster? all related data (...)') )."');\" ";
		$string .= "/>";
		$string .= "<input type='hidden' name='name' value='".$subscription->GetName()."' />";
		$string .= "</div>";
		$string .= "</form>";
		
		return $string;
	}
}

?>